//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<engine_debug.h>
///	@path	~/src/engine/xcore/
///	@date	2007/11/10
///	@desc	Method for engine debug.

#pragma once

#include "xeres.h"

#include "lib/system/lock.h"

#include "database/DataManager.h"

#include "graphics/IFont.h"
#include "graphics/IGeometry.h"
#include "graphics/canvas/CCanvas.h"
#include "graphics/canvas/CCanvasText.h"
#include "graphics/animation/frame.h"

namespace xeres {

	// forward declaration
	class Engine;

	/*!
		\class	EngineDebug
		\brief	Debug functions for engine.
	*/
	class EngineDebug
	{
	protected:

		/// \name Constructor & Destructor
		//@{

		/// \ctor
		EngineDebug( void );

		/// \dtor
		~EngineDebug( void );

		//@}

		/// \name Internal Manipulation
		//@{

		/*!
			\brief		Initialize engine debugger.
		*/
		void Initialize( RefWeak<IRenderer> renderer );

		/*!
			\brief		Finalize engine debugger.
		*/
		void Finalize( void );

	public:

		/*!
			\brief		Tick update.
		*/
		void Tick( const Frame& frame );

		/*!
			\brief		Render debug screen.
		*/
		void Render( RenderContext& rc );

		//@}

		/// \name Debug Query
		//@{

		/// \brief		Statistic engine update time.
		void StatEngineTime( double ms );


		//@}

	private:

		friend class Engine;

		// system defined variables

		double				m_fpsStatElapse;
		double				m_fpsAcc;

		// fps
		Ref<IVar>			m_fps;

		// watched variables

		Ref<CCanvas>		m_canvas;

		// fps
		Ref<CCanvasText>	m_fpsText;
		Ref<IFont>			m_fpsFont;
	};

} // namespace xeres
